﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SpriteMaker;
namespace UIMaker
{
    public partial class FramePreview : Control
    {
        private Frame frame;
        private Image image;
        public FramePreview()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            pe.Graphics.Clear(Color.Gray);
            if (frame != null && image != null)
            {
                foreach (FrameModule frameModule in frame.frameModuleList)
                {
                    pe.Graphics.DrawImage(image
                    , new Rectangle(frameModule.x + 0, frameModule.y + 0, frameModule.module.width, frameModule.module.height)
                        , new Rectangle(frameModule.module.x, frameModule.module.y, frameModule.module.width, frameModule.module.height), GraphicsUnit.Pixel);
                }
            }
        }
        public void SetActiveFrame(Frame f)
        {
            frame = f;
        }
        public void SetActiveImage(Image i)
        {
            image = i;
        }
    }
}
